package com.gxwy.shenzhou;

public class HeaderResponse implements StringHandler{
	private String len;
	public static final int LEN_LEN=8;
	public static final int LEN_FLAG=1;
	private String jydm;
	public static final int JYDM_LEN=4;
	public static final int JYDM_FLAG=2;
	private String jyrq;
	public static final int JYRQ_LEN=8;
	public static final int JYRQ_FLAG=2;
	private String jysj;
	public static final int JYSJ_LEN=6;
	public static final int JYSJ_FLAG=2;
	private String msgid;
	public static final int MSGID_LEN=5;
	public static final int MSGID_FLAG=2;
	private String xccfcs;
	public static final int XCCFCS_LEN=4;
	public static final int XCCFCS_FLAG=2;
	private String jygzh;
	public static final int JYGZH_LEN=16;
	public static final int JYGZH_FLAG=2;
	private String gylsh;
	public static final int GYLSH_LEN=8;
	public static final int GYLSH_FLAG=2;
	private String ggmsgid;
	public static final int GGMSGID_LEN=6;
	public static final int GGMSGID_FLAG=2;
	private String ggcfcs;
	public static final int GGCFCS_LEN=4;
	public static final int GGCFCS_FLAG=2;
	private String ggjyrq;
	public static final int GGJYRQ_LEN=8;
	public static final int GGJYRQ_FLAG=2;
	private String ggjysj;
	public static final int GGJYSJ_LEN=6;
	public static final int GGJYSJ_FLAG=2;
	private String ggweizhi;
	public static final int GGWEIZHI_LEN=16;
	public static final int GGWEIZHI_FLAG=2;
	public static final int TOTAL_LEN=LEN_LEN+JYDM_LEN+JYRQ_LEN+JYSJ_LEN+MSGID_LEN+XCCFCS_LEN+JYGZH_LEN+
			GYLSH_LEN+GGMSGID_LEN+GGCFCS_LEN+GGJYRQ_LEN+GGJYSJ_LEN+GGWEIZHI_LEN;
	private int reallen=0;
	public String getLen() {
		return len;
	}
	public void setLen(String len) throws Exception {
		if(len==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(len.getBytes("gbk").length<LEN_LEN){
			this.len=Supply.supply(len, LEN_FLAG, LEN_LEN);
		}else if(len.getBytes("gbk").length>LEN_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.len = len;			
		}
	}
	public String getJydm() {
		return jydm;
	}
	public void setJydm(String jydm) throws Exception {
		if(jydm==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(jydm.getBytes("gbk").length<JYDM_LEN){
			this.jydm=Supply.supply(jydm, JYDM_FLAG, JYDM_LEN);
		}else if(jydm.getBytes("gbk").length>JYDM_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.jydm = jydm;			
		}
	}
	public String getJyrq() {
		return jyrq;
	}
	public void setJyrq(String jyrq) throws Exception {
		if(jyrq==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(jyrq.getBytes("gbk").length<JYRQ_LEN){
			this.jyrq=Supply.supply(jyrq, JYRQ_FLAG, JYRQ_LEN);
		}else if(jyrq.getBytes("gbk").length>JYRQ_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.jyrq = jyrq;			
		}
	}
	public String getJysj() {
		return jysj;
	}
	public void setJysj(String jysj) throws Exception {
		if(jysj==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(jysj.getBytes("gbk").length<JYSJ_LEN){
			this.jysj=Supply.supply(jysj, JYSJ_FLAG, JYSJ_LEN);
		}else if(jysj.getBytes("gbk").length>JYSJ_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.jysj = jysj;			
		}
	}
	public String getMsgid() {
		return msgid;
	}
	public void setMsgid(String msgid) throws Exception {
		if(msgid==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(msgid.getBytes("gbk").length<MSGID_LEN){
			this.msgid=Supply.supply(msgid, MSGID_FLAG, MSGID_LEN);
		}else if(msgid.getBytes("gbk").length>MSGID_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.msgid = msgid;			
		}
	}
	public String getXccfcs() {
		return xccfcs;
	}
	public void setXccfcs(String xccfcs) throws Exception {
		if(xccfcs==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(xccfcs.getBytes("gbk").length<XCCFCS_LEN){
			this.xccfcs=Supply.supply(xccfcs, XCCFCS_FLAG, XCCFCS_LEN);
		}else if(xccfcs.getBytes("gbk").length>XCCFCS_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.xccfcs = xccfcs;			
		}
	}
	public String getJygzh() {
		return jygzh;
	}
	public void setJygzh(String jygzh) throws Exception {
		if(jygzh==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(jygzh.getBytes("gbk").length<JYGZH_LEN){
			this.jygzh=Supply.supply(jygzh, JYGZH_FLAG, JYGZH_LEN);
		}else if(jygzh.getBytes("gbk").length>JYGZH_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.jygzh = jygzh;			
		}
	}
	public String getGylsh() {
		return gylsh;
	}
	public void setGylsh(String gylsh) throws Exception {
		if(gylsh==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(gylsh.getBytes("gbk").length<GYLSH_LEN){
			this.gylsh=Supply.supply(gylsh, GYLSH_FLAG, GYLSH_LEN);
		}else if(gylsh.getBytes("gbk").length>GYLSH_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.gylsh = gylsh;			
		}
	}
	public String getGgmsgid() {
		return ggmsgid;
	}
	public void setGgmsgid(String ggmsgid) throws Exception {
		if(ggmsgid==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(ggmsgid.getBytes("gbk").length<GGMSGID_LEN){
			this.ggmsgid=Supply.supply(ggmsgid, GGMSGID_FLAG, GGMSGID_LEN);
		}else if(ggmsgid.getBytes("gbk").length>GGMSGID_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.ggmsgid = ggmsgid;			
		}
	}
	public String getGgcfcs() {
		return ggcfcs;
	}
	public void setGgcfcs(String ggcfcs) throws Exception {
		if(ggcfcs==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(ggcfcs.getBytes("gbk").length<GGCFCS_LEN){
			this.ggcfcs=Supply.supply(ggcfcs, GGCFCS_FLAG, GGCFCS_LEN);
		}else if(ggcfcs.getBytes("gbk").length>GGCFCS_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.ggcfcs = ggcfcs;			
		}
	}
	public String getGgjyrq() {
		return ggjyrq;
	}
	public void setGgjyrq(String ggjyrq) throws Exception {
		if(ggjyrq==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(ggjyrq.getBytes("gbk").length<GGJYRQ_LEN){
			this.ggjyrq=Supply.supply(ggjyrq, GGJYRQ_FLAG, GGJYRQ_LEN);
		}else if(ggjyrq.getBytes("gbk").length>GGJYRQ_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.ggjyrq = ggjyrq;			
		}
	}
	public String getGgjysj() {
		return ggjysj;
	}
	public void setGgjysj(String ggjysj) throws Exception {
		if(ggjysj==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(ggjysj.getBytes("gbk").length<GGJYSJ_LEN){
			this.ggjysj=Supply.supply(ggjysj, GGJYSJ_FLAG, GGJYSJ_LEN);
		}else if(ggjysj.getBytes("gbk").length>GGJYSJ_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.ggjysj = ggjysj;			
		}
	}
	public String getGgweizhi() {
		return ggweizhi;
	}
	public void setGgweizhi(String ggweizhi) throws Exception {
		if(ggweizhi==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(ggweizhi.getBytes("gbk").length<GGWEIZHI_LEN){
			this.ggweizhi=Supply.supply(ggweizhi, GGWEIZHI_FLAG, GGWEIZHI_LEN);
		}else if(ggweizhi.getBytes("gbk").length>GGWEIZHI_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.ggweizhi = ggweizhi;			
		}
	}
	
	
	@Override
	public String toString() {
		return "HeaderResponse [len=" + len + ", jydm=" + jydm + ", jyrq="
				+ jyrq + ", jysj=" + jysj + ", msgid=" + msgid + ", xccfcs="
				+ xccfcs + ", jygzh=" + jygzh + ", gylsh=" + gylsh
				+ ", ggmsgid=" + ggmsgid + ", ggcfcs=" + ggcfcs + ", ggjyrq="
				+ ggjyrq + ", ggjysj=" + ggjysj + ", ggweizhi=" + ggweizhi
				+ ", reallen=" + reallen + "]";
	}
	public String build() throws Exception{
		if(this.getLen()==null){
			this.setLen("");
		}
		if(this.getJydm()==null){
			this.setJydm("");
		}
		if(this.getJyrq()==null){
			this.setJyrq("");
		}
		if(this.getJysj()==null){
			this.setJysj("");
		}
		if(this.getMsgid()==null){
			this.setMsgid("");
		}
		if(this.getXccfcs()==null){
			this.setXccfcs("");
		}
		if(this.getJygzh()==null){
			this.setJygzh("");
		}
		if(this.getGylsh()==null){
			this.setGylsh("");
		}
		if(this.getGgmsgid()==null){
			this.setGgmsgid("");
		}
		if(this.getGgcfcs()==null){
			this.setGgcfcs("");
		}
		if(this.getGgjyrq()==null){
			this.setGgjyrq("");
		}
		if(this.getGgjysj()==null){
			this.setGgjysj("");
		}
		if(this.getGgweizhi()==null){
			this.setGgweizhi("");
		}
		return this.getLen()+this.getJydm()+this.getJyrq()+this.getJysj()+this.getMsgid()+
				this.getXccfcs()+this.getJygzh()+this.getGylsh()+this.getGgmsgid()+this.getGgcfcs()+
				this.getGgjyrq()+this.getGgjysj()+this.getGgweizhi();
	}
	
	public void parse(String str) throws Exception{
		if(str==null){
			Exception e=new Exception("String is null");
			 throw e;
		}else if(str.getBytes("gbk").length<TOTAL_LEN){
			Exception e=new Exception("Invalid request");
			 throw e;
		}else{
			this.setLen(SplitString.splitString(str,reallen, reallen+LEN_LEN));
			reallen+=LEN_LEN;
			this.setJydm(SplitString.splitString(str,reallen, reallen+JYDM_LEN));
			reallen+=JYDM_LEN;
			this.setJyrq(SplitString.splitString(str,reallen, reallen+JYRQ_LEN));
			reallen+=JYRQ_LEN;
			this.setJysj(SplitString.splitString(str,reallen, reallen+JYSJ_LEN));
			reallen+=JYSJ_LEN;
			this.setMsgid(SplitString.splitString(str,reallen, reallen+MSGID_LEN));
			reallen+=MSGID_LEN;
			this.setXccfcs(SplitString.splitString(str,reallen, reallen+XCCFCS_LEN));
			reallen+=XCCFCS_LEN;
			this.setJygzh(SplitString.splitString(str,reallen, reallen+JYGZH_LEN));
			reallen+=JYGZH_LEN;
			this.setGylsh(SplitString.splitString(str,reallen, reallen+GYLSH_LEN));
			reallen+=GYLSH_LEN;
			this.setGgmsgid(SplitString.splitString(str,reallen, reallen+GGMSGID_LEN));
			reallen+=GGMSGID_LEN;
			this.setGgcfcs(SplitString.splitString(str,reallen, reallen+GGCFCS_LEN));
			reallen+=GGCFCS_LEN;
			this.setGgjyrq(SplitString.splitString(str,reallen, reallen+GGJYRQ_LEN));
			reallen+=GGJYRQ_LEN;
			this.setGgjysj(SplitString.splitString(str,reallen, reallen+GGJYSJ_LEN));
			reallen+=GGJYSJ_LEN;
			this.setGgweizhi(SplitString.splitString(str,reallen, reallen+GGWEIZHI_LEN));
			reallen+=GGWEIZHI_LEN;
		}
	}
}
